{include file="kuyou/common/menu" /}
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="row">
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-4">{:__('Purchase_code')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <input id="c-purchase_code" class="form-control" data-rule="required" value="{$code|default=''}" name="row[purchase_code]" type="text" placeholder="{:__('Purchase_code')}">
                </div>
            </div>
        </div>
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-4">{:__('Customers_id')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <input type="hidden" id="customers_id" name="row[customers_id]" value="">
                    <div id="customers_ids" class="xm-select-demo"></div>
                </div>
            </div>
        </div>
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-4"> {:__('Total outstanding debt')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <input id="c-arrears" readonly name="row[arrears]" class="form-control" type="text" value="" placeholder=" {:__('Total outstanding debt')}">
                </div>
            </div>
        </div>
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-4"> {:__('payee')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <select name="row[staff_member_id]" id="staff_member_id" class="form-control">
                        <option value="">{:__('Please choose')} {:__('payee')}</option>
                        {foreach name="saleList" item="vo"}
                        <option value="{$vo.id}" {if condition="isset($row['staff_member_id']) && $vo.id==$row.staff_member_id"}selected{/if}>{$vo.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-4">{:__('Purchase_time')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <input id="c-purchase_time" class="form-control datetime" name="row[purchase_time]" type="text" value="{:date('Y-m-d')}" placeholder="{:__('Purchase_time')}">
                </div>
            </div>
        </div>
    </div>

    <div class="table_box">
        <div class="list" style="overflow-x: auto">
            <table id="account_table">
                <tr>
                    <th></th><th>{:__('Settlement account')}</th><th>{:__('Amount Collected ')}</th><th>{:__('Payment method')}</th><th>{:__('Settlement number')}</th><th>{:__('remarks')}</th>
                </tr>
                <tr style="display: none;">
                    <td><div class="btn"><span class="ac_add"><i class="fa fa-plus"></i></span><span class="ac_del"><i class="fa fa-trash"></i></span></div></td>
                    <td>
                        <select name="row[accounts_id][]" class="form-control accounts_id">
                            <option value=""></option>
                            {foreach name="accountsList" item="vo"}
                            <option value="{$vo.id}">{$vo.account_name}</option>
                            {/foreach}
                        </select>
                    </td>
                    <td><input type="number" name="row[money][]" class="account_money number_decimal"></td>
                    <td>
                        <select name="row[settlementtype][]" class="form-control settlementtype">
                            <option value=""></option>
                            {foreach name="settlementtype" item="vo"}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/foreach}
                        </select>
                    </td>
                    <td><input type="text" name="row[number][]" class="number"></td>
                    <td><input type="text" name="row[remark][]" class="remark"></td>
                </tr>
                <tr>
                    <td><div class="btn"><span class="ac_add"><i class="fa fa-plus"></i></span><span class="ac_del"><i class="fa fa-trash"></i></span></div></td>
                    <td>
                        <select name="row[accounts_id][]" class="form-control accounts_id">
                            <option value=""></option>
                            {foreach name="accountsList" item="vo"}
                            <option value="{$vo.id}">{$vo.account_name}</option>
                            {/foreach}
                        </select>
                    </td>
                    <td><input type="number" name="row[money][]" class="account_money number_decimal"></td>
                    <td>
                        <select name="row[settlementtype][]" class="form-control settlementtype">
                            <option value=""></option>
                            {foreach name="settlementtype" item="vo"}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/foreach}
                        </select>
                    </td>
                    <td><input type="text" name="row[number][]" class="number"></td>
                    <td><input type="text" name="row[remark][]" class="remark"></td>
                </tr>
                <tr>
                    <td><div class="btn"><span class="ac_add"><i class="fa fa-plus"></i></span><span class="ac_del"><i class="fa fa-trash"></i></span></div></td>
                    <td>
                        <select name="row[accounts_id][]" class="form-control accounts_id">
                            <option value=""></option>
                            {foreach name="accountsList" item="vo"}
                            <option value="{$vo.id}">{$vo.account_name}</option>
                            {/foreach}
                        </select>
                    </td>
                    <td><input type="number" name="row[money][]" class="account_money number_decimal"></td>
                    <td>
                        <select name="row[settlementtype][]" class="form-control settlementtype">
                            <option value=""></option>
                            {foreach name="settlementtype" item="vo"}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/foreach}
                        </select>
                    </td>
                    <td><input type="text" name="row[number][]" class="number"></td>
                    <td><input type="text" name="row[remark][]" class="remark"></td>
                </tr>
                <tr>
                    <td><div class="btn"><span class="ac_add"><i class="fa fa-plus"></i></span><span class="ac_del"><i class="fa fa-trash"></i></span></div></td>
                    <td>
                        <select name="row[accounts_id][]" class="form-control accounts_id">
                            <option value=""></option>
                            {foreach name="accountsList" item="vo"}
                            <option value="{$vo.id}">{$vo.account_name}</option>
                            {/foreach}
                        </select>
                    </td>
                    <td><input type="number" name="row[money][]" class="account_money number_decimal"></td>
                    <td>
                        <select name="row[settlementtype][]" class="form-control settlementtype">
                            <option value=""></option>
                            {foreach name="settlementtype" item="vo"}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/foreach}
                        </select>
                    </td>
                    <td><input type="text" name="row[number][]" class="number"></td>
                    <td><input type="text" name="row[remark][]" class="remark"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><div>{:__('total')}</div></td>
                    <td><div><input type="text" readonly class="number_hj"></div></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
            </table>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <div class="form-group" style="margin: 0;text-align: right">
                <button type="button" id="chose" class="btn btn-default btn-embossed">{:__('Select source order')}</button>
            </div>
        </div>
    </div>
    <div class="table_box">
        <div class="list" style="overflow-x: auto">
            <table id="sale_table">
                <tr>
                    <th></th><th>{:__('Source Order Number')}</th><th>{:__('Business category')}</th><th>{:__('Document date')}</th><th>{:__('Document amount')}</th><th>{:__('Verified amount')}</th><th>{:__('Unrecognized amount')}</th><th>{:__('The amount to be verified this time')}</th><th>{:__('remarks')}</th><th class="hiddens"></th><th class="hiddens"></th>
                </tr>
                <tr style="display: none;">
                    <td><div class="btn"><span class="add"><i class="fa fa-plus"></i></span><span class="del"><i class="fa fa-trash"></i></span></div></td>
                    <td><input type="text" readonly name="row[purchase_number][]" class="purchase_number"></td>
                    <td><input type="text" readonly name="row[business_type][]" class="business_type"></td>
                    <td><input type="text" readonly name="row[times][]" class="times"></td>
                    <td><input type="text" readonly name="row[sale_money][]" class="sale_money"></td>
                    <td><input type="text" readonly name="row[write_off][]" class="write_off"></td>
                    <td><input type="text" readonly name="row[write_off_money][]" class="write_off_money"></td>
                    <td><input type="number" name="row[write_off_price][]" class="write_off_price number_decimal"></td>
                    <td><input type="text" readonly name="row[sale_remark][]" class="sale_remark"></td>
                    <td class="hiddens"><input type="text" readonly name="row[purchase_type][]" class="purchase_type"></td>
                    <td class="hiddens"><input type="text" readonly name="sale[purchase_numbers][]" class="purchase_numbers"></td>
                </tr>
                <tr>
                    <td><div class="btn"><span class="add"><i class="fa fa-plus"></i></span><span class="del"><i class="fa fa-trash"></i></span></div></td>
                    <td><input type="text" readonly name="row[purchase_number][]" class="purchase_number"></td>
                    <td><input type="text" readonly name="row[business_type][]" class="business_type"></td>
                    <td><input type="text" readonly name="row[times][]" class="times"></td>
                    <td><input type="text" readonly name="row[sale_money][]" class="sale_money"></td>
                    <td><input type="text" readonly name="row[write_off][]" class="write_off"></td>
                    <td><input type="text" readonly name="row[write_off_money][]" class="write_off_money"></td>
                    <td><input type="number" name="row[write_off_price][]" class="write_off_price number_decimal"></td>
                    <td><input type="text" readonly name="row[sale_remark][]" class="sale_remark"></td>
                    <td class="hiddens"><input type="text" readonly name="row[purchase_type][]" class="purchase_type"></td>
                    <td class="hiddens"><input type="text" readonly name="row[purchase_numbers][]" class="purchase_numbers"></td>
                </tr>
                <tr>
                    <td><div class="btn"><span class="add"><i class="fa fa-plus"></i></span><span class="del"><i class="fa fa-trash"></i></span></div></td>
                    <td><input type="text" readonly name="row[purchase_number][]" class="purchase_number"></td>
                    <td><input type="text" readonly name="row[business_type][]" class="business_type"></td>
                    <td><input type="text" readonly name="row[times][]" class="times"></td>
                    <td><input type="text" readonly name="row[sale_money][]" class="sale_money"></td>
                    <td><input type="text" readonly name="row[write_off][]" class="write_off"></td>
                    <td><input type="text" readonly name="row[write_off_money][]" class="write_off_money"></td>
                    <td><input type="number" name="row[write_off_price][]" class="write_off_price number_decimal"></td>
                    <td><input type="text" readonly name="row[sale_remark][]" class="sale_remark"></td>
                    <td class="hiddens"><input type="text" readonly name="row[purchase_type][]" class="purchase_type"></td>
                    <td class="hiddens"><input type="text" readonly name="row[purchase_numbers][]" class="purchase_numbers"></td>
                </tr>
                <tr>
                    <td><div class="btn"><span class="add"><i class="fa fa-plus"></i></span><span class="del"><i class="fa fa-trash"></i></span></div></td>
                    <td><input type="text" readonly name="row[purchase_number][]" class="purchase_number"></td>
                    <td><input type="text" readonly name="row[business_type][]" class="business_type"></td>
                    <td><input type="text" readonly name="row[times][]" class="times"></td>
                    <td><input type="text" readonly name="row[sale_money][]" class="sale_money"></td>
                    <td><input type="text" readonly name="row[write_off][]" class="write_off"></td>
                    <td><input type="text" readonly name="row[write_off_money][]" class="write_off_money"></td>
                    <td><input type="number" name="row[write_off_price][]" class="write_off_price number_decimal"></td>
                    <td><input type="text" readonly name="row[sale_remark][]" class="sale_remark"></td>
                    <td class="hiddens"><input type="text" readonly name="row[purchase_type][]" class="purchase_type"></td>
                    <td class="hiddens"><input type="text" readonly name="row[purchase_numbers][]" class="purchase_numbers"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><div>{:__('total')}：</div></td>
                    <td></td>
                    <td></td>
                    <td><input type="text" readonly class="sale_money_hj"></td>
                    <td><input type="text" readonly class="write_off_hj"></td>
                    <td><input type="text" readonly class="write_off_money_hj"></td>
                    <td><input type="text" readonly class="write_off_price_hj"></td>
                    <td></td>
                    <td class="hiddens"></td>
                    <td class="hiddens"></td>
                </tr>
            </table>
        </div>
    </div>

    <div class="row" style="margin-bottom: 10px;">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <textarea id="c-note" class="form-control" rows="4" name="row[note]" cols="30" placeholder="{:__('remarks')}信息">{$row.note|default=''}</textarea>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-4"> {:__('Whole order discount')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <input id="c-discount" class="form-control discount" step="0.01" name="row[discount]" type="number" value="{$row.discount|default=''}" placeholder=" {:__('Whole order discount')}">
                </div>
            </div>
        </div>
        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="form-group">
                <label class="control-label col-xs-12 col-sm-4"> {:__('This advance payment')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <input id="c-advance" class="form-control advance price_decimal" step="0.01" name="row[advance]" type="number" value="{$row.advance|default=''}" placeholder=" {:__('This advance payment')}">
                </div>
            </div>
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button style="display: none" id="surebtns" type="submit" class="btn btn-success btn-embossed">{:__('OK')}</button>
            <button type="button" id="surebtn" class="btn btn-success btn-embossed">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
